<?php
/**
 * @deprecated
 * Description:淘宝客相关Api调用服务
 * Author: hezhizheng
 * Date: 2018/5/7
 * Time: 11:02
 * Created by Created by Panxsoft.
 */

namespace App\Services\TaoBao;


//use Orzcc\TopClient\Facades\TopClient;
use Orzcc\TopClient\Facades\TopClient;
use TopClient\request\TbkItemConvertRequest;
use TopClient\request\TbkItemGetRequest;


class TaoBaoTopService
{

    /**
     * 淘宝客商品查询
     * 标题、图片、淘宝价、价格、销量
     * @return mixed
     */
    public function TbkItemGetRequest() //
    {
        $topclient = TopClient::connection();
        $req = new TbkItemGetRequest;
        $req->setFields("num_iid,title,pict_url,reserve_price,zk_final_price,user_type,provcity,item_url");
        $req->setQ('手机');
        $req->setSort("tk_total_sales");
        $req->setPageNo('1'); // 实验后发现必需用字符串的数字才能正确分页
        $req->setPageSize('40');
        $resp = $topclient->execute($req);
        return $resp;
    }


    /**
     *
     * @deprecated
     * 淘宝客商品链接转换(没有权限)
     *
     * @return mixed
     */
    public function TbkItemConvertRequest() // 淘宝客商品链接转换
    {
        $topclient = TopClient::connection();
        $req = new TbkItemConvertRequest();
        $req->setFields("num_iid,title,pict_url,reserve_price,zk_final_price,user_type,provcity,item_url");
        $req->setNumIids("123,456");
        $req->setAdzoneId("123");
        $req->setPlatform("123");
        $req->setUnid("demo");
//        $req->setDx("1");
        $resp = $topclient->execute($req);

        return $resp;
    }


}